<template>
  <div>
    <div class="factory-box">
      <div class="tab-btns">
        <div class="btn1" @click="showBox('btn1')" :class="{on: showBtns == 'btn1'}">
          装配高位货架
          <div class="line"></div>
          <div class="btns-box">
            <div class="box-title">装配高位货架</div>
            <div class="box-content">
              <div class="btn" @click="toDetail('btn1','kucun')">库存</div>
              <div class="btn" @click="toDetail('btn1','wuliu')">物流</div>
            </div>
          </div>
        </div>
        <div class="btn2" @click="showBox('btn2')" :class="{on: showBtns == 'btn2'}">
          料箱立库
          <div class="line"></div>
          <div class="btns-box">
            <div class="box-title">料箱立库</div>
            <div class="box-content">
              <div class="btn" @click="toDetail('btn2','kucun')">库存</div>
              <div class="btn" @click="toDetail('btn2','wuliu')">物流</div>
            </div>
          </div>
        </div>
        <div class="btn3" @click="showBox('btn3')" :class="{on: showBtns == 'btn3'}">
          托盘立库
          <div class="line"></div>
          <div class="btns-box">
            <div class="box-title">托盘立库</div>
            <div class="box-content">
              <div class="btn" @click="toDetail('btn3','kucun')">库存</div>
              <div class="btn" @click="toDetail('btn3','wuliu')">物流</div>
            </div>
          </div>
        </div>
        <div class="btn4" @click="showBox('btn4')" :class="{on: showBtns == 'btn4'}">
          装配平地库
          <div class="line"></div>
          <div class="btns-box">
            <div class="box-title">装配平地库</div>
            <div class="box-content">
              <div class="btn" @click="toDetail('btn4','kucun')">库存</div>
              <div class="btn" @click="toDetail('btn4','wuliu')">物流</div>
            </div>
          </div>
        </div>
        <div class="btn5 unusual" @click="showBox('btn5')" :class="{on: showBtns == 'btn5'}">
          装配
          <div class="line"></div>
          <div class="btns-box">
            <div class="box-title">装配</div>
            <div class="box-content">
              <div class="btn" @click="toDetail('btn5','oee')">OEE</div>
              <div class="btn warning" @click="toDetail('btn5','dingdan')">订单</div>
            </div>
          </div>
        </div>
        <div class="btn8">产品库</div>
        <div class="btn9">排序发货</div>
        <div class="btn10">金切</div>
        <div class="btn11">电泳</div>
        <div class="btn12">焊接</div>
        <div class="btn13">焊接平地库</div>
        <div class="btn14">焊接高位货架</div>
      </div>
      厂区整体运行状况图
    </div>
    <div class="status-box">
      <div class="title">运行状态</div>
      <div class="wrapper">
        <div class="box unusual">
          <div class="text text1">
            客户订单/
            生产计划
          </div>
          <div class="tip">异常</div>
         </div>
        <div class="box but" v-on:click="toggleOee">
          <div class="text">OEE</div>
          <div class="tip">正常</div>
        </div>
        <div class="box">
          <div class="text">库存状态</div>
          <div class="tip">正常</div>
        </div>
        <div class="box">
          <div class="text">物流数据</div>
          <div class="tip">正常</div>
        </div>
      </div>
    </div>
    <div class="sidebar-right" v-show="showOee">
      <div class="bar-box">
        <div class="title">
          <div class="title-right">
            <div class="title-bg">节拍对比</div>
          </div>
        </div>
        <div class="content">
          <div class="content-bg">
            <div class="bar-item">
              <Bar2 :chart-id="chart3Id" :chart-data="seriesData3"/>
            </div>
          </div>
          <div class="content-bottom"></div>
        </div>
      </div>
    </div>
    <Modal v-model="modal1">
      <!--<p slot="header" style="text-align:center;">-->
        <!--<span> 自制件半成品清单</span>-->
      <!--</p>-->
      <div class="bar-box">
        <div class="title">
          <div class="title-right">
            <div class="title-bg">自制件半成品清单</div>
          </div>
        </div>
        <div class="box-content">
          <div style="height: 360px;">
            <div>
              <ul class="alarmList" style="height: 340px;">
                <li>
                  <Row>
                    <Col span="4">
                    <div class="modal_title">物料号</div>
                    </Col>
                    <Col span="4">
                    <div class="modal_title">图号</div>
                    </Col>
                    <Col span="7">
                    <div class="modal_title">物料名称</div>
                    </Col>
                    <Col span="3">
                    <div class="modal_title">仓库</div>
                    </Col>
                    <Col span="3">
                    <div class="modal_title">库存</div>
                    </Col>
                    <Col span="3">
                    <div class="modal_title">库存资金</div>
                    </Col>
                  </Row>
                </li>
                <li>
                  <Row>
                    <Col span="4">
                    <div class="modal_item">item.ITEM_CODE</div>
                    </Col>
                    <Col span="4">
                    <div class="modal_item">item.OLD_ITEM_CODE</div>
                    </Col>
                    <Col span="7">
                    <div class="modal_item">item.ITEM_NAME</div>
                    </Col>
                    <Col span="3">
                    <div class="modal_item">item.WAREHOUSE_COD</div>
                    </Col>
                    <Col span="3">
                    <div class="modal_item">item.MES_QTY</div>
                    </Col>
                    <Col span="3">
                    <div class="modal_item">item.TOTAL_PRICE</div>
                    </Col>
                  </Row>
                </li>
              </ul>
            </div>
          </div>
        </div>
      </div>
      <!--<div slot="footer">-->
      <!--<Button type="info" size="large" long  @click="cancel">关闭</Button>-->
      <!--</div>-->
    </Modal>
  </div>
</template>
<script>
import Bar from '../components/Bar.vue'
import Bar2 from '../components/Bar2.vue'
import input1 from '../components/input.vue'
import input2 from '../components/input2.vue'
import { Modal } from 'iview'
export default {
  name: 'index',
  components: {
    input1,
    input2,
    Bar,
    Bar2,
    Modal
  },
  data () {
    return {
      modal1: true,
      showBtns: '',
      seriesData3: {
        max: 15,
        legendData: ['标准节拍', '实际节拍'],
        data: {}
      },
      chart3Id: 'chart3',
      chart3Data: [
        {
          num1: 8,
          num2: 10
        }
      ],
      showOee: false
    }
  },
  mounted () {
    this.seriesData3.data = this.getSeriesData(this.chart3Data)
  },
  methods: {
    showBox (num) {
      this.showBtns = num
    },
    toDetail (num, type) {
      let pageInfo = {
        num: num,
        type: type
      }
      localStorage.setItem('pageInfo', JSON.stringify(pageInfo))
      this.$router.push({path: '/assemblyline'})
    },
    getSeriesData (data) {
      let seriesData = {
        names: [],
        series1: [],
        series2: []
      }
      for (let i = 0; i < data.length; i++) {
        if (data[i].name) {
          seriesData.names.push(data[i].name)
        }
        if (data[i].num1) {
          seriesData.series1.push(data[i].num1)
        }
        if (data[i].num2) {
          seriesData.series2.push(data[i].num2)
        }
      }
      return seriesData
    },
    toggleOee () {
      this.showOee = !this.showOee
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .status-box {
    width: 319px;
    margin-left: 67px;
    margin-top: 5px;
    color: #ffffff;
    position: absolute;
  }
  .status-box .title {
    background: url(../assets/title-bg.png) no-repeat;
    background-size: cover;
    background-position: center center;
    height: 53px;
    font-size: 20px;
    line-height: 53px;
  }
  .status-box .wrapper {
    width:300px;
    height:300px;
    background:rgba(26,96,255,0.2);
    margin: 10px;
    padding: 2px;
    border:2px solid rgba(56, 72, 199, 1);
  }
  .status-box .box {
    width:140px;
    height:140px;
    background:rgba(6,30,126,1);
    border:2px solid rgba(33, 137, 255, 1);
    border-radius:10px;
    float: left;
    margin: 3px;
    box-shadow: 0 0 30px 5px #2189FF inset;
    font-size: 24px;
    color: #2FFEFE;
  }
  .status-box .box.but {
    cursor: pointer;
  }
  .status-box .text {
    width: 110px;
    text-align: center;
    margin: 30px auto;
    line-height: 1.2;
    font-weight: bold;
  }
  .status-box .text.text1 {
    margin: 16px auto;
  }
  .status-box .tip {
    position: relative;
    margin: 0 auto;
    padding-left: 33px;
    font-size: 20px;
    color: #24DF5D;
  }
.status-box .tip:before {
  content: '';
  display: block;
  position: absolute;
  left: 28px;
  top: -2px;
  margin: 3px;
  width:24px;
  height:24px;
  background:rgba(0,255,42,0);
  border:2px solid rgba(20, 174, 45, 1);
  box-shadow:0px 1px 10px 0px rgba(0,255,42,1);
  border-radius:50%;
}
.status-box .tip:after {
  content: '';
  width: 14px;
  height: 14px;
  display: block;
  position: absolute;
  left: 33px;
  top: 3px;
  background-color: #24DF5D;
  border-radius: 15px;
  margin: 3px;
}
  .status-box .box.unusual {
    background:rgba(6,30,126,1);
    border:2px solid #FA4D28;
    border-radius:10px;
    float: left;
    margin: 3px;
    box-shadow: 0 0 30px 5px #FA4D28 inset;
    font-size: 24px;
    color: #2FFEFE;
  }
  .status-box .unusual .tip:before {
    border:2px solid #FA4D28;
    box-shadow:0px 1px 10px 0px #FA4D28;
  }
  .status-box .unusual .tip:after {
    background-color: #FA4D28;
  }
.status-box .box.unusual .tip {
  color: #FA4D28;
}
.status-box .box.unusual .text {
  color: red;
}
  .factory-box {
    background: url('../assets/factory1.png') no-repeat;
    background-size: cover;
    width: 1610px;
    position: absolute;
    left: 226px;
    bottom: 0;
    color: #AEC9FF;
    font-size: 24px;
    padding-top: 680px;
    padding-bottom: 35px;
  }
  .tab-btns {
    color: #ffffff;
    font-size: 16px;
  }
  .tab-btns > div {
    background-color: rgba(103,133,206,0.9);
    border-radius: 50px;
    padding: 0 15px;
    display: inline-block;
    position: absolute;
    cursor: pointer;
  }
  .tab-btns > div.unusual {
    background-color:rgba(201,20,54,1);
    box-shadow:0 0 40px 20px #FE3A5E;
  }
  .tab-btns .btn1 {
    left: 117px;
    top: 243px;
  }
  .tab-btns .btn2 {
    left: 163px;
    top: 355px;
  }
  .tab-btns .btn3 {
    left: 150px;
    top: 430px;
  }
  .tab-btns .btn4 {
    left: 257px;
    top: 405px;
  }
  .tab-btns .btn5 {
    left: 323px;
    top: 213px;
  }
  .tab-btns .btn8 {
    left: 555px;
    top: 166px;
  }
  .tab-btns .btn9 {
    left: 671px;
    top: 178px;
  }
  .tab-btns .btn10 {
    left: 794px;
    top: 299px;
  }
  .tab-btns .btn11 {
    left: 948px;
    top: 153px;
  }
  .tab-btns .btn12 {
    left: 1042px;
    top: 153px;
  }
  .tab-btns .btn13 {
    left: 1110px;
    top: 81px;
  }
  .tab-btns .btn14 {
    left: 1150px;
    top: 148px;
  }
  .tab-btns .btns-box {
    position: absolute;
    top: -336px;
    right: -138px;
    width: 140px;
    z-index: 99;
    display: none;
    padding: 3px;
    background: rgba(0,7,54,0.9);
    border:1px solid #0080CA;
    box-shadow:0px 0px 30px 0px rgba(0,128,202,0.8) inset;
    border-radius:8px;
  }
  .tab-btns .line {
    background: url('../assets/line.png') no-repeat;
    background-size: 40px auto;
    width: 40px;
    height: 248px;
    position: absolute;
    display: none;
    right: 0;
    z-index: 99;
    top: -250px;
  }
  .tab-btns .on .line, .tab-btns .on .btns-box {
    display: block;
  }
  .tab-btns .btns-box .box-title {
    color: #ffffff;
    font-size: 20px;
    font-weight: bold;
    margin: 5px 0 0;
  }
  .tab-btns .btns-box .box-content .btn {
    height:40px;
    line-height: 40px;
    background:rgba(0,3,54,0.24);
    border:2px solid rgba(69, 116, 214, 1);
    border-radius:5px;
    width: 90%;
    font-weight: bold;
    margin: 5%;
    box-shadow: 0 0 15px 3px #2189FF inset;
  }
  .tab-btns .btns-box .box-content .btn.warning {
    background:rgba(201,20,54,0.24);
    border:2px solid rgba(201, 20, 54, 1);
    box-shadow: 0 0 15px 3px #FA4D28 inset;
  }
  .sidebar-right {
    float: right;
    width: 495px;
    margin-right: 58px;
  }
  .ivu-modal-body .bar-box .title {
    margin: -60px 0 0 -24px;
  }
  .ivu-modal-body .box-content {
    margin: 20px 0;
  }
</style>
